<template>
	<view>
		<Navbar :isReturn="false"></Navbar>
		<u-tabs-swiper ref="tabs" active-color="#B3723E" bg-color="transparent" :is-scroll="false" :current="tab.current"
			:list="tab.list" @change="tabChange"></u-tabs-swiper>

		<view v-show="[0].includes(tab.current)">
			<view class="group_box" :style="{top: stickyTop + 'px'}">
				<view class="u-m-l-20 u-m-r-20 u-p-t-15 u-p-b-15 u-flex u-row-between">
					<view class="group_drop">
						<u-dropdown ref="uDropdown" menu-icon="arrow-down-fill" menu-icon-size="16"
							@iconClick="iconClick">
							<u-dropdown-item title="筛查">
								<view class="slot-content"></view>
							</u-dropdown-item>
						</u-dropdown>
					</view>

					<view class="group_search">
						<u-search shape="round" v-model="keyword" bg-color="#F3F4F6" :show-action="false"
							:clearabled="false" height="70" placeholder="搜索青创私董/地址等" @search="search"></u-search>
					</view>
					<view class="group_switch u-font-24">
						<view class="switch_box" v-for="item in switchList" :key="item.id"
							:class="item.check ? 'active' : ''" @click="goSwitch(item)">{{item.name}}</view>
					</view>
				</view>
			</view>

			<view class="u-p-t-30 u-m-l-30 u-m-r-30" v-show="[1].includes(switchValue)">
				<GroupBox :list="groupList" @addPerson="addPerson" @callMobile="callMobile" @goDetail="goDetail"> 
				</GroupBox>
				<Loadmore :status="loadStatus"></Loadmore>
			</view>
			<view class="map_box" v-show="[2].includes(switchValue)" :style="{height: mapHeight + 'px'}">
				<view v-if="locationShow" @click="onSetLocation">
					<u-image width="100%" :height="`${mapHeight}px`"
						src="https://lrcj.oss-cn-shenzhen.aliyuncs.com/images/common/20240828956056207421.png"></u-image>
				</view>
				<map id="map" :latitude="latitude" :longitude="longitude" :markers="markers" @markertap="markertap" :scale="17" :min-scale="13.25" @regionchange="regionchange" v-else>
				</map>
				<view class="map_current_box" v-if="markersCurrent.longitude !== longitude">
					<view class="map_current_btn" @click.native.stop="onGoBackLoaction">回到当前位置</view>
				</view>
				<!-- <view class="map_tag_box" v-if="!locationShow">
					<view class="map_tag" @click="onSelectMap(1,1)">
						<u-icon name="shechang" custom-prefix="custom-icon" color="#EF1F1F" size="32"></u-icon>
						<view class="u-m-l-10">找青创私董</view>
					</view>
					<view class="map_tag" @click="onSelectMap(1,2)">
						<u-icon name="laoxiang" custom-prefix="custom-icon" color="#FFBF61" size="32"></u-icon>
						<view class="u-m-l-10">找老乡</view>
					</view>
					<view class="map_tag" @click="onOpenSelect()">
						<u-icon name="gengduomore12" custom-prefix="custom-icon" color="#FFBF61" size="32"></u-icon>
						<view class="u-m-l-10">找更多</view>
					</view>
				</view> -->
			</view>
		</view>

		<view class="u-m-30" v-show="[1,2,3].includes(tab.current)">
			<view class="u-m-b-30" v-if="[1,2].includes(tab.current)">
				<u-search placeholder="请输入关键词" v-model="keyword" height="80" :clearabled="false" bg-color="#fff"
					@search="searchFriend" @custom="searchFriend"></u-search>
			</view>
			<GroupBox ref="friendBox" :groupType="groupType" :list="friendList" @callMobile="callMobile"
				@cardApply="cardApply" @onChooseLabel="onChooseLabel"></GroupBox>
			<Loadmore :status="loadStatus"></Loadmore>
		</view>

		<!-- 筛查弹出层 -->
		<u-popup v-model="selectPopupShow" length="90%" mode="bottom" border-radius="20">
			<view style="height: 100%;">
				<scroll-view scroll-y="true" class="slot-scroll" style="height: 85%;">
					<view v-for="selectItem in selectList" :key="selectItem.id">
						<view class="moreOptionBox" v-if="![6].includes(selectItem.id)">
							<view class="moreOptionTitle">{{selectItem.title}}</view>
							<view class="u-m-t-20">
								<u-row gutter="20">
									<u-col span="4" v-for="childItem in selectItem.list" :key="childItem.label">
										<view class="checkOptionBox u-m-b-20"
											:class="childItem.check ? 'checkStatus' : ''"
											@click="checkData(childItem,selectItem)">
											{{childItem.label}}
										</view>
									</u-col>
								</u-row>
							</view>
						</view>
						<view class="moreIndustryBox" v-else>
							<view class="moreOptionTitle">{{selectItem.title}}</view>
							<view class="u-m-t-20 u-flex u-col-top u-row-between industryBox">
								<view class="u-flex-1 industryItemBox">
									<view class="industryItem"
										:class="oneItem.industry_id == industryOne.checkObj.industry_id ? 'active' : ''"
										v-for="oneItem in industryOne.list" :key="oneItem.industry_id"
										@click="checkIndustry(oneItem,1)">{{ oneItem.industry_name }}</view>
								</view>
								<scroll-view style="height: 100%;flex: 1" scroll-y="true">
									<view class="backF8">
										<view class="industryItem"
											:class="twoItem.industry_id == industryTwo.checkObj.industry_id ? 'active' : ''"
											v-for="twoItem in industryTwo.list" :key="twoItem.industry_id"
											@click="checkIndustry(twoItem,2)">{{ twoItem.industry_name }}</view>
									</view>
								</scroll-view>
							</view>
						</view>
					</view>
				</scroll-view>
				<view style="height: 80rpx;"></view>

				<view class="u-flex u-m-l-32 u-p-b-40 u-m-r-32 u-row-between">
					<button class="reserve" @click="toReserve">重置</button>
					<button class="confirm" @click="toConfirm">确定</button>
				</view>
			</view>
		</u-popup>

		<!-- 地图标注点信息-->
		<u-popup mode="bottom" border-radius="20" v-model="marker.show" id="markersPopup">
			<view>
				<view class="u-m-30">
					<view class="u-card-box">
						<view class="u-flex">
							<u-image width="160rpx" height="160rpx"
								:src="marker.data.head_img"></u-image>
							<view class="u-m-l-20 u-flex-1 u-flex-col u-row-between u-ellipsis" style="height: 160rpx;">
								<view class="u-flex u-row-between">
									<view class="u-flex">
										<view class="u-font-bold u-font-34 u-m-r-10">{{marker.data.name}}</view>
										<!-- <view class="u-m-r-10" v-if="![0,'0'].includes(marker.data.sex)">
											<u-icon size="32" :color="marker.data.sex == 1 ? '#4399FF' : '#FF69B1'"
												:name="marker.data.sex == 1 ? 'nanxing' : 'nvxing'"
												custom-prefix="custom-icon" />
										</view> -->
										<view class="u-m-r-10" v-if="marker.data.is_authentication == 2">
											<u-icon size="32" color="#FB6316" name="renzheng"
												custom-prefix="custom-icon" />
										</view>
										<view class="u-m-r-10" v-if="marker.data.is_company_user == 1">
											<u-icon size="32" color="#F8494D" name="qiye1"
												custom-prefix="custom-icon" />
										</view>
										<view class="u-back-red u-tag-box" :class="marker.data.president_class"
											v-if="[5,6,7,8].includes(marker.data.president_status) && marker.data.president_class">
											{{ getPresidentName(marker.data.partner_status,marker.data.president_status) }}
										</view>
									</view>

								</view>
								<view class="u-m-t-10 u-color-gray u-ellipsis u-font-25">
									{{marker.data.address}}
								</view>
								<view class="u-m-t-10 u-flex u-row-between u-font-25">
									<view class="u-color-puce">
										<span>能量值：</span>
										<span class="u-font-bold u-font-26">{{marker.data.number}}</span>
									</view>
									<view class="u-color-blue" @click="goPersonDetail(marker.data.id)">查看详情 ></view>
								</view>
							</view>
						</view>
						<view class="u-flex u-col-top u-m-t-10 u-text-line-15" v-if="marker.data.advantage">
							<view class="u-color-puce u-font-bold">企业优势：</view>
							<text :user-select="true" class="u-text-line-15 u-flex-1">{{marker.data.advantage}}</text>
						</view>

						<view class="u-flex u-col-top u-m-t-10 u-text-line-15" v-if="marker.data.resources">
							<span class="u-color-puce u-font-bold">个人资源：</span>
							<text :user-select="true" class="u-text-line-15 u-flex-1">{{marker.data.resources}}</text>
						</view>
						<view class="u-flex u-col-top u-m-t-10 u-text-line-15" v-if="marker.data.recommend">
							<span class="u-color-puce u-font-bold">需要的引荐：</span>
							<text :user-select="true" class="u-text-line-15 u-flex-1">{{marker.data.recommend}}</text>
						</view>
					</view>
					<view class="u-m-t-30 u-m-b-30"
						v-if="marker.data.company_res.id && marker.data.company_res.status == 1">
						<view class="u-m-b-30 u-font-bold u-font-40">公司：</view>
						<view class="u-exhibiton-box u-m-b-20 u-flex u-row-between"><!-- @click="goConventionDetail(marker.data.company_res.id)" -->
							<u-image width="150rpx" height="150rpx" :src="marker.data.company_res.logo"
								mode="aspectFit"></u-image>
							<view class="u-flex-1 u-flex-col u-row-between u-m-l-20 u-ellipsis" style="height: 150rpx;">
								<view class="u-font-32 u-ellipsis u-font-bold">{{marker.data.company_res.company_name}}
								</view>
								<view class="u-flex">
									<view class="u-m-l-10 convention_tag u-back-linear"
										v-for="item2 in marker.data.company_res.industry_names" :key="item2">{{item2}}
									</view>
								</view>

								<view class="u-flex u-row-between u-font-24 u-color-gray u-ellipsis">
									<view class="u-color-gray u-ellipsis">{{marker.data.company_res.address}}</view>
								</view>
							</view>
						</view>
					</view>
				</view>
				<view style="height: 40rpx;"></view>
			</view>
		</u-popup>

		<Modal :show="modal.show" :confirmText="modal.confirm" :modalContent="modal.content"
			:showCancel="modal.showCancel" @confirm="modalConfirm" @cancel="modal.show = false"></Modal>

		<RegisterModal :registerShow="showModal" @close="showModal = false"></RegisterModal>

		<RemarkPopup :userRemark="remarkText" :popupShow="remarkShow" @popupClose="remarkShow = false"
			@confirm="remarkConfirm"></RemarkPopup>

		<Tabbar id="tabbar"></Tabbar>
	</view>
</template>

<script>
	import Navbar from '@/components/Navbar.vue'
	import Tabbar from '@/components/Tabbar.vue'
	import Loadmore from '@/components/Loadmore.vue'
	import Modal from '@/components/Modal.vue'
	import GroupBox from '@/components/GroupBox.vue'
	import RegisterModal from '@/components/RegisterModal.vue'
	import RemarkPopup from '@/components/RemarkPopup.vue'
	import {
		groupSelectList,
		PresidentLevel,
    TeaStatus,
		call,
		throttle,
		presidentClass,
		flattenObj,
		debounce,
		pointTransform
	} from '@/utils/index.js'
	import {
		getClassAIndustry,
		getClassBIndustry,
		userInfo,
		singleIntegral,
		businessCardApply,
		getShare,
		userFriendDetail,
		mapList,
		friendList,
		businessCardExchange,
		cardSubmit,
		cardNumber,
		userRelationDel,
		userRemark
	} from '@/network/api.js'
	import {
		groupList,
		teaFriendList
	} from '@/network/tea.js'
	import reachBottom from '@/mixins/reachBottom.js'
	import share from '@/mixins/share.js'
	export default {
		mixins: [reachBottom, share],
		components: {
			Navbar,
			Tabbar,
			Loadmore,
			Modal,
			GroupBox,
			RegisterModal,
			RemarkPopup
		},
		data() {
			return {
				tab: {
					current: 0,
					list: [{
						name: '全部'
					}, {
						name: '好友'
					}, {
						name: '来友'
					}, {
						name: '审核',
						count: 0
					}]
				},
				latitude: '',
				longitude: '',
				range: 0.006, // 请求范围
				scale: 17, // 地图缩放等级
				markers: [], // 地图标注点集合
				markersId: [], // 标注点id集合
				markersCurrent: {
					id: -1,
					latitude: 0,
					longitude: 0,
					width: '60rpx',
					height: '69rpx',
					alpha: 1,
					iconPath: "https://lrcj.oss-cn-shenzhen.aliyuncs.com/images/common/20241203934058455383.png"
				},
				/* 标注点选中弹出层 */
				marker: {
					show: false,
					data: {}
				},
				switchList: [{
						id: 1,
						name: '列表',
						check: false
					},
					{
						id: 2,
						name: '地图',
						check: true
					},
				],
				selectList: groupSelectList(),
				groupList: [], // 人脉列表
				groupType: 0,
				friendList: [], // 好友、来友、审核列表
				keyword: "",
				switchValue: 0,
				selectPopupShow: false,
				/* 一级行业 */
				industryOne: {
					list: [],
					checkObj: {}
				},
				/* 二级行业 */
				industryTwo: {
					list: [],
					checkObj: {}
				},
				/* 三级行业 */
				industryThree: {},
				/* 弹出提示 */
				modal: {
					show: false,
					showCancel: true,
					confirm: '确定',
					content: '',
					isDelete: 0, // 删除好友
					id: '' // 删除记录id
				},
				stickyTop: 0,
				mapHeight: 0,
				fromUserId: 0,
				showModal: false,
				remarkShow: false,
				remarkText: '',
				locationShow: false,
				user_id: uni.getStorageSync("user_id"),
				loadStatus: 'loadmore'
			}
		},
		onLoad() {
			const _this = this
      wx.hideShareMenu()
			uni.getLocation({
				type: 'gcj02',
				success: function(res) {
					if (res.errMsg == "getLocation:ok") {
						_this.longitude = res.longitude
						_this.latitude = res.latitude
						_this.markersCurrent.longitude = res.longitude
						_this.markersCurrent.latitude = res.latitude
						_this.getMapList()
					}
				},
				fail: function(err) {
					_this.switchValue = 2
					_this.locationShow = true
				},
			})
			this.getFirstIndustry()
			this.handleGetShare()
			this.handleGetStickyTop()
		},
		onShow() {
			if (this.switchValue == 1 && getApp().globalData.switchCustom) {
				this.switchList.forEach(item => item.check = false)
				this.switchList[0].check = true
				this.groupList = []
				this.page = 1
				this.loadStatus = 'loadmore'
				this.getGroupList()
				getApp().globalData.switchCustom = false
			}
			this.handleGetCardNumber()
		},
		methods: {
			handleGetShare() {
				getShare({
					key: 'group'
				}).then(res => {
					res.data.page = `${res.data.page}?inviterId=${uni.getStorageSync("user_id")}`
					this.mixinsShare = res.data
          setTimeout(() => {
            wx.showShareMenu({
              withShareTicket: true,
              menus: ['shareAppMessage', 'shareTimeline']
            })
          }, 1000)
				})
			},
			handleGetCardNumber() {
				cardNumber({
					userid: this.user_id
				}).then(res => {
					this.tab.list[3].count = res.data.number
				})
			},
			handleGetStickyTop() {
				const _this = this
				uni.getSystemInfo({
					success: (res) => {
						const statusBarHeight = res.statusBarHeight || 0;
						const menuButtonInfo = uni.getMenuButtonBoundingClientRect();
						const navBarHeight = menuButtonInfo.height + (menuButtonInfo.top - statusBarHeight) *
							2;
						const topIconDistance = statusBarHeight + navBarHeight - 7;
						_this.stickyTop = topIconDistance
						uni.createSelectorQuery().in(this).select("#tabbar").boundingClientRect(data => {
							uni.createSelectorQuery().in(this).select(".group_box").boundingClientRect(
								selectData => {
									let selectHeight = data.height
									_this.mapHeight = res.screenHeight - res.statusBarHeight -
										navBarHeight - data.height - selectData.height - 40
									/* 屏幕可视高度 - 顶部系统栏高度 - navbar高度 - tabbar高度 - 筛查模块高度 - tab高度 */
								}).exec()
						}).exec()
					},
					fail: (err) => {}
				})
			},
			handleParams() {
				const params = {
					user_id: uni.getStorageSync("user_id"),
					keyword: this.keyword,
					page: this.page,
					limit: this.pageSize,
				}
				this.selectList.forEach(item => {
					switch (item.id) {
						case 1:
							params.is_president = item.list[0].check == true ? 1 : ''
							break;
						case 2:
							params.is_village = item.list[0].check == true ? 1 : ''
							break;
						case 3:
							params.sex = item.list.find(ageItem => ageItem.check == true).value
							break;
						case 4:
							params.is_friend = item.list[0].check == true ? 1 : ''
							break;
						case 5:
							params.is_tea_friend = item.list[0].check == true ? 1 : ''
							break;
						case 6:
							params.industry_id = this.industryThree.industry_id || ''
							break;
					}
				})
				return params
			},
			getGroupList() {
				/* 获取人脉列表 */
				uni.showLoading({
					title: "加载中"
				})
				let select = this.handleParams()
				groupList(select).then(res => {
					if (res.data.list.length > 0) {
						res.data.list.forEach(item => {
							item.president_status = parseInt(item.president_status)
							item.president_name = this.getPresidentName(item.partner_status,item.president_status)
							item.president_class = presidentClass(item.president_status)
							if (item.tengxun_address !== null) {
								item.address =
									`${item.tengxun_address.city}${item.tengxun_address.district}${item.address}`
							}
							item.number = pointTransform(item.number)
							this.groupList.push(item)
						})
					}
					if (res.data.list.length < 10) this.loadStatus = 'nomore'
					uni.hideLoading()
				})
			},
			getMapList: debounce(function() {
				uni.showLoading({
					title: "加载中"
				})
				/* 获取地图标注点 */
				const params = {
					user_id: this.user_id,
					longitude: this.longitude,
					latitude: this.latitude,
					range: this.range
				}
				this.markers = []
				mapList(params).then(res => {
					for (let i = 0; i < res.data.list.length; i++) {
						const params = {
							id: res.data.list[i].id,
							latitude: Number(res.data.list[i].latitude),
							longitude: Number(res.data.list[i].longitude),
							width: this.scale <= 16 ? '20rpx' : '33rpx',
							height: this.scale <= 16 ? '20rpx' : '38rpx',
							alpha: 0.8,
							president_status: parseInt(res.data.list[i].president_status),
							iconPath: this.scale <= 16 ? ([5, 6, 7, 8].includes(parseInt(res.data.list[
										i]
									.president_status)) ?
								'https://lrcj.oss-cn-shenzhen.aliyuncs.com/images/common/20241213107990399323.png' :
								'https://lrcj.oss-cn-shenzhen.aliyuncs.com/images/common/20241213407465511480.png'
								) : ([5, 6, 7, 8].includes(parseInt(res.data.list[i]
									.president_status)) ?
								"http://medv-new.oss-cn-shanghai.aliyuncs.com/images/common/20240620761358155382.png" :
								"http://medv-new.oss-cn-shanghai.aliyuncs.com/images/common/20240527883963438040.png"
								),
							iconImage: [5, 6, 7, 8].includes(parseInt(res.data.list[i]
									.president_status)) ?
								"http://medv-new.oss-cn-shanghai.aliyuncs.com/images/common/20240620761358155382.png" :
								"http://medv-new.oss-cn-shanghai.aliyuncs.com/images/common/20240527883963438040.png",
							label: {
								content: this.scale <= 16 ? '' : `${res.data.list[i].name}`,
								text: `${res.data.list[i].name}`,
								color: "#000",
								fontSize: "24rpx",
								textAlign: "center",
								padding: 2,
							}
						}
						this.markers.push(params)
						this.markersId.push(res.data.list[i].id)
					}
					this.markers.push(this.markersCurrent)
					this.switchValue = 2
					setTimeout(() => {
						uni.hideLoading()
					}, 3000)
				})
			}, 300),
			markertap(val) {
				if (val.markerId == -1) {
					return
				} else {
					uni.showLoading({
						title: "正在加载中"
					})
					this.markers.forEach((item, index) => {
						if (item.id !== -1 && item.id == val.markerId) {
							item.iconPath =
								'https://lrcj.oss-cn-shenzhen.aliyuncs.com/images/common/20241203934058455383.png'
							item.callout = {
								content: `${item.label.text}`,
								color: '#fff',
								fontSize: 13,
								borderRadius: 6,
								borderColor: '#fff',
								borderWidth: 2,
								padding: 8,
								bgColor: [5, 6, 7, 8].includes(item.president_status) ? '#F57E77' : '#348EF3',
								display: 'ALWAYS',
							}
							item.label.content = ''
							const [element] = this.markers.splice(index, 1)
							this.markers.push(element)
						} else {
							if (item.label && item.callout) {
								item.iconPath = this.scale <= 16 ? ([5, 6, 7, 8].includes(item.president_status) ?
									'https://lrcj.oss-cn-shenzhen.aliyuncs.com/images/common/20241213107990399323.png' :
									'https://lrcj.oss-cn-shenzhen.aliyuncs.com/images/common/20241213407465511480.png'
									) : item.iconImage
								item.callout = {}
								item.label.content = this.scale <= 16 ? '' : item.label.text
							}
						}
					})
					const params = {
						user_id: val.markerId,
						from_user_id: uni.getStorageSync("user_id")
					}
					userFriendDetail(params).then(res => {
						res.data.president_status = parseInt(res.data.president_status)
						res.data.president_class = presidentClass(res.data.president_status)
						if (res.data.tengxun_address !== null) {
							res.data.address =
								`${res.data.tengxun_address.city}${res.data.tengxun_address.district}${res.data.address}`
						}
						this.marker.data = res.data
						this.marker.show = true
						uni.hideLoading()
					})
				}
			},
			regionchange(val) {
				if (val.causedBy == 'scale') {
					this.scale = val.detail.scale
					if (val.detail.scale > 18) {
						this.range = 0.006
						this.getMapList()
					}
					if (15 < val.detail.scale <= 18) {
						this.range = 0.006
					}
					if (14 < val.detail.scale <= 15) {
						this.range = 0.008
					}
					if (13.75 < val.detail.scale <= 14) {
						this.range = 0.01
						this.getMapList()
					}
					if (13.25 < val.detail.scale <= 13.75) {
						this.range = 0.03
					}
				}
				if (val.type == 'end') {
					let long = Math.abs(val.detail.centerLocation.longitude - this.longitude)
					let lat = Math.abs(val.detail.centerLocation.latitude - this.latitude)
					if (this.scale <= 13.75 && (long > 0.02 || lat > 0.02)) {
						this.longitude = val.detail.centerLocation.longitude
						this.latitude = val.detail.centerLocation.latitude
						this.getMapList()
					}
					if (13.75 < this.scale <= 15 && (long > 0.01 || lat > 0.01)) {
						this.longitude = val.detail.centerLocation.longitude
						this.latitude = val.detail.centerLocation.latitude
						this.getMapList()
					}
					if (this.scale > 15 && (long > 0.003 || lat > 0.003)) {
						this.longitude = val.detail.centerLocation.longitude
						this.latitude = val.detail.centerLocation.latitude
						this.getMapList()
					}
				}
			},
			tabChange(val) {
				this.tab.current = val
				this.keyword = ''
				this.page = 1
				this.groupList = []
				this.friendList = []
				this.loadStatus = 'loadmore'
				switch (val) {
					case 0:
						this.getGroupList()
						break;
					case 1:
					case 2:
					case 3:
						this.getFriendList(val)
						break;
				}
			},
			getFriendList(val) {
				let reqUrl = friendList
				switch (val) {
					case 1:
						reqUrl = friendList
						this.groupType = 1
						break;
					case 2:
						reqUrl = teaFriendList
						this.groupType = 2
						break;
					case 3:
						reqUrl = businessCardExchange
						this.groupType = 3
						break;
				}
				const params = {
					user_id: this.user_id,
					page: this.page,
					limit: this.pageSize,
					keyword: this.keyword
				}
				reqUrl(params).then(res => {
					switch (val) {
						case 1:
							if (res.data.length > 0) {
								res.data.map(item => {
									item.president_status = parseInt(item.president_status)
									item.president_name = this.getPresidentName(item.partner_status,item.president_status)
									item.president_class = presidentClass(item.president_status)
									if (item.tengxun_address !== null) {
										item.address =
											`${item.tengxun_address.city}${item.tengxun_address.district}${item.address}`
									}
									item.label_list = []
									item.evaluate_content = ''
									this.friendList.push(item)
								})
							}
							if (res.data.length < 10) this.loadStatus = 'nomore'
							break;
						case 2:
							if (res.data.list.length > 0) {
								res.data.list.map(item => {
									item.user_info.president_name = this.getPresidentName(item.user_info.partner_status,item.user_info.president_status)
									item.user_info.president_class = presidentClass(item.user_info
										.president_status)
									if (item.user_info.tengxun_address !== null) {
										item.user_info.address =
											`${item.user_info.tengxun_address.city}${item.user_info.tengxun_address.district}${item.user_info.address}`
									}
									let params = {
										label_list: item.label_list,
										evaluate_content: item.evaluate_content,
										data_num: item.data_num
									}
									item = {
										...flattenObj(item.user_info),
										...params
									}
									this.friendList.push(item)
								})
							}
							if (res.data.list.length < 10) this.loadStatus = 'nomore'
							break;
						case 3:
							if (res.data.length > 0) {
								res.data.map(item => {
									item.president_status = parseInt(item.president_status)
									item.president_name = this.getPresidentName(item.partner_status,item.president_status)
									item.president_class = presidentClass(item.president_status)
									item.label_list = []
									item.evaluate_content = ''
									if (item.tengxun_address !== null) {
										item.address =
											`${item.tengxun_address.city}${item.tengxun_address.district}${item.address}`
									}
									if (item.is_exchange == "0") {
										this.friendList.push(item)
									}
								})
							}
							this.loadStatus = 'nomore'
							break;
					}
				})
			},
			goSwitch(val) {
				this.switchList.forEach(item => item.check = false)
				val.check = true
				this.switchValue = val.id
				if (val.id == 1) {
					this.groupList.length = 0
					this.page = 1
					this.getGroupList()
				}
			},
			goConventionDetail(val) {
				uni.navigateTo({
					url: "/pages/conventionDetail/conventionDetail?id=" + val
				})
			},
			search(val) {
				this.switchValue = 1
				this.switchList.forEach(item => item.check = false)
				this.switchList[0].check = true
				this.groupList.length = 0
				this.page = 1
				this.getGroupList()
			},
			searchFriend(val) {
				this.friendList.length = 0
				this.page = 1
				this.getFriendList(this.tab.current)
			},
			getFirstIndustry() {
				/* 获取一级行业标签 */
				getClassAIndustry().then(res => {
					this.industryOne.list = res.data
					this.industryOne.checkObj = res.data[0]
					this.getTwoIndustry(res.data[0].industry_id)
				})
			},
			getPresidentName(status1, status2) {
        return TeaStatus(status1, status2)
				// return PresidentLevel(status)
			},
			checkData(val, data) {
				/* 下拉筛选单选 */
				data.list.forEach(item => {
					if (item.value == val.value) {
						val.check = !val.check
					} else {
						item.check = false
					}
				})
			},
			checkIndustry(data, type) {
				/* 选中行业 */
				switch (type) {
					case 1:
						this.industryOne.checkObj = data
						this.industryThree = {}
						this.getTwoIndustry(data.industry_id)
						break;
					case 2:
						this.industryThree = data
						// this.industryThree = {}
						this.industryTwo.checkObj = data
						break;
					case 3:
						this.industryThree = data
						break;
				}
			},
			getTwoIndustry(id) {
				getClassBIndustry({
					pid: id
				}).then(res => {
					this.industryTwo.list = res.data
					this.industryTwo.checkObj = res.data[0]
				})
			},
			addPerson(id) {
				/* 添加好友 */
				this.fromUserId = id
				/* const params = {
					key: "ExchangeCards",
					type: 0
				}
				singleIntegral(params).then(res => {
					this.modal.content = `交换名片需要消耗${res.data.value}积分，请问是否仍要继续？`
					this.modal.show = true
				}) */
				this.modal.content = `交换名片，对方同意后交换成功`
				this.modal.show = true
			},
			callMobile(val) {
				call(val)
			},
			iconClick() {
				this.selectPopupShow = true
			},
			modalConfirm() {
				/* 提示弹出层确认按钮 */
				this.modal.show = false
				const userBlack = uni.getStorageSync("user_isBlack")
				if (userBlack == 0) {
					if (this.modal.isDelete == 1) {
						userRelationDel({
							card_id: this.modal.id
						}).then(res => {
							uni.showToast({
								title: `${res.msg}`,
								icon: "none"
							})
							this.modal.isDelete = 0
							this.friendList.length = 0
							this.page = 1
							this.getFriendList(1)
						})
					} else {
						userInfo({
							user_id: this.user_id
						}).then(res => {
							let integral = res.data.integral // 用户积分
							const params = {
								key: "ExchangeCards",
								type: 0
							}
							singleIntegral(params).then(singleRes => {
								let singleIntegral = singleRes.data.value
								if (parseInt(integral) < parseInt(singleIntegral)) {
									uni.showToast({
										title: "积分不足",
										icon: "none"
									})
								} else {
									const applyParams = {
										user_id: this.user_id,
										from_user_id: this.fromUserId
									}
									businessCardApply(applyParams).then(applyRes => {
										uni.showToast({
											title: `${applyRes.msg}`,
											icON: "none"
										})
									})
								}
							})
						})
					}
				}
			},
			toReserve() {
				/* 重置筛选 */
				this.switchValue = 1
				this.switchList.forEach(item => item.check = false)
				this.switchList[0].check = true
				this.selectList.forEach(item => {
					if (item.id == 3) {
						item.list.forEach(ageItem => ageItem.check = false)
						item.list[0].check = true
					}
					if ([1, 2, 4, 5].includes(item.id)) {
						item.list[0].check = false
					}
				})
				this.industryOne.checkObj = {}
				this.industryTwo.checkObj = {}
				this.industryThree = {}
				this.groupList = []
				this.page = 1
				this.loadStatus = 'loadmore'
				this.getGroupList()
				// this.$refs.uDropdown.close()
				this.$refs.uDropdown.contentHeight = 0
				this.selectPopupShow = false
			},
			toConfirm() {
				/* 确认筛选 */
				this.switchValue = 1
				this.switchList.forEach(item => item.check = false)
				this.switchList[0].check = true
				this.groupList = []
				this.page = 1
				this.loadStatus = 'loadmore'
				this.getGroupList()
				// this.$refs.uDropdown.close()
				this.$refs.uDropdown.contentHeight = 0
				this.selectPopupShow = false
			},
			onSelectMap(value, id) {
				this.selectList.forEach(item => {
					if (item.id == 3) {
						item.list.forEach(ageItem => ageItem.check = false)
						item.list[0].check = true
					}
					if ([1, 2, 4, 5].includes(item.id)) {
						item.list[0].check = false
					}
				})
				this.selectList.forEach(item => {
					if (item.id == id) {
						item.list.forEach(item2 => item2.check = false)
						item.list.forEach(item3 => {
							if (item3.value == value) {
								item3.check = true
							}
						})
					}
				})
				this.switchValue = 1
				this.switchList.forEach(item => item.check = false)
				this.switchList[0].check = true
				this.groupList = []
				this.page = 1
				this.loadStatus = 'loadmore'
				this.getGroupList()
			},
			onOpenSelect() {
				this.selectPopupShow = true
			},
			goDetail(val) {
				const userStauts = uni.getStorageSync("user_status")
				if (userStauts == 0) {
					this.showModal = true
				} else {
					uni.showLoading({
						title: "加载中"
					})
					this.switchList.forEach(item => item.check = false)
					this.switchList[1].check = true
					this.tab.current = 0
					this.switchValue = 2
					setTimeout(() => {
						this.openUserMapDetail(val)
					}, 500)
				}
			},
			openUserMapDetail(id) {
				/* 点击打开用户在地图中的标注 */
				this.markers.show = false
				if (this.markersId.includes(id)) {
					this.markers.map(item => {
						if (item.id == id) {
							item.width = '66rpx',
								item.height = '76rpx'
							this.latitude = item.latitude
							this.longitude = item.longitude
							const params = {
								user_id: id,
								from_user_id: uni.getStorageSync("user_id")
							}
							userFriendDetail(params).then(res => {
								res.data.president_status = parseInt(res.data.president_status)
								res.data.president_class = presidentClass(res.data.president_status)
								if (res.data.tengxun_address !== null) {
									res.data.address =
										`${res.data.tengxun_address.city}${res.data.tengxun_address.district}${res.data.address}`
								}
								this.marker.data = res.data
								this.marker.show = true
								uni.hideLoading()
							})
						}
					})
				} else {
					const params = {
						user_id: id,
						from_user_id: uni.getStorageSync("user_id")
					}
					userFriendDetail(params).then(res => {
						res.data.president_status = parseInt(res.data.president_status)
						res.data.president_class = presidentClass(res.data.president_status)
						this.latitude = Number(res.data.latitude)
						this.longitude = Number(res.data.longitude)
						if (res.data.tengxun_address !== null) {
							res.data.address =
								`${res.data.tengxun_address.city}${res.data.tengxun_address.district}${res.data.address}`
						}
						this.marker.data = res.data
						this.marker.show = true
						const params = {
							id: Number(res.data.id),
							latitude: Number(res.data.latitude),
							longitude: Number(res.data.longitude),
							width: '66rpx',
							height: '76rpx',
							alpha: 0.8,
							iconPath: [5, 6, 7, 8].includes(parseInt(res.data.president_status)) ?
								"http://medv-new.oss-cn-shanghai.aliyuncs.com/images/common/20240620761358155382.png" :
								"http://medv-new.oss-cn-shanghai.aliyuncs.com/images/common/20240527883963438040.png",
							label: {
								content: `${res.data.name}`,
								text: `${res.data.name}`,
								color: "#000",
								fontSize: "24rpx",
								textAlign: "center",
								padding: 1
							}
						}
						this.markers.push(params)
						uni.hideLoading()
					})
				}
			},
			goPersonDetail(id) {
				this.marker.show = false
				const userStauts = uni.getStorageSync("user_status")
				const userBlack = uni.getStorageSync("user_isBlack")
				if (userBlack == 0) {
					if (userStauts == 0) {
						this.showModal = true
					} else {
						uni.navigateTo({
							url: "/teaBureau/teaPersonDetail/teaPersonDetail?id=" + id
						})
					}
				} else {
					this.modal.content = '当前用户权限受限，请联系系统管理员'
					this.modal.confirmText = '确定'
					this.modal.show = true
				}
			},
			cardApply(val) {
				cardSubmit(val).then(res => {
					uni.showToast({
						title: `${res.msg}`,
						icon: "none"
					})
					this.friendList = []
					this.page = 1
					this.handleGetCardNumber()
					this.getFriendList(3)
				})
			},
			onChooseLabel(val) {
				switch (val.type) {
					case 1:
						this.$refs.friendBox.commonPopup.show = false
						this.modal.id = val.id
						this.modal.content = `请确认是否要解除好友关系？`
						this.modal.isDelete = 1
						this.modal.show = true
						break;
					case 2:
						this.$refs.friendBox.commonPopup.show = false
						this.modal.id = val.id
						this.remarkShow = true
						this.remarkText = val.remark
						break;
				}
			},
			remarkConfirm(val) {
				const params = {
					user_id: this.user_id,
					from_user_id: this.modal.id,
					remark: val
				}
				userRemark(params).then(res => {
					uni.showToast({
						title: `${res.msg}`
					})
					this.remarkShow = false
					this.friendList.length = 0
					this.page = 1
					this.getFriendList(this.tab.current)
				})
			},
			onSetLocation() {
				const _this = this
				uni.openSetting({
					success: (res) => {
						if (res.authSetting['scope.userLocation']) {
							uni.getLocation({
								type: 'gcj02',
								success: function(res) {
									if (res.errMsg == "getLocation:ok") {
										_this.locationShow = false
										_this.longitude = res.longitude;
										_this.latitude = res.latitude;
										_this.getMapList()
									}
								},
								fail: function(err) {
									_this.switchValue = 2
									_this.locationShow = true
								},
							})
						}
					}
				})
			},
			onGoBackLoaction() {
				this.longitude = this.markersCurrent.longitude
				this.latitude = this.markersCurrent.latitude
				this.getMapList()
			},
			loadData() {
				if (this.loadStatus == 'nomore') return
				this.page++
				this.loadStatus = 'loading'
				this.getGroupList()
			}
		}
	}
</script>

<style lang="scss" scoped>
	::v-deep .u-dropdown__menu__item {
		background-color: #F3F4F6;
		color: #9397A4;
		padding: 0 30rpx;
		border-radius: 38rpx;
		height: 100%;
	}

	::v-deep .u-dropdown__menu__item__text {
		font-size: 24rpx !important;
		color: #9EA2AE !important;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}

	::v-deep .u-dropdown__content {
		width: 100vw !important;
		left: -30rpx !important
	}

	::v-deep #markersPopup .u-drawer-content {
		max-height: 60vh;
	}

	::v-deep #markersPopup .u-drawer__scroll-view {
		max-height: 60vh;
	}

	.group_box {
		position: sticky;
		z-index: 10000;
	}

	.group_switch {
		display: flex;
		justify-content: space-between;
		align-items: center;
		background-color: #F3F4F6;
		height: 70rpx;
		line-height: 70rpx;
		border-radius: 38rpx;

		.switch_box {
			height: 100%;
			padding: 0 25rpx;
			border-radius: 38rpx;
			transition: all .5s;
		}

		.active {
			background: #B67642;
			color: #fff;
		}
	}

	.slot-content {
		background: #fff;
		height: 100%;
		border-bottom: 1px solid #f7f7f7;
		border-bottom-left-radius: 20rpx;
		border-bottom-right-radius: 20rpx;

		.slot-scroll {
			height: 800rpx;
			box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.5);
		}
	}

	.moreOptionBox {
		padding: 20rpx 0px;
		margin: 0 20rpx;

		.moreOptionTitle {
			font-size: 32rpx;
			font-weight: bold;
			margin-left: 10rpx;
		}

		.checkOptionBox {
			background: #F7F7F7;
			color: #000;
			padding: 20rpx 0;
			text-align: center;
			font-size: 24rpx;
			border-radius: 10rpx;
		}

		.checkStatus {
			background: #fb6316;
			color: #fff;
		}
	}

	.moreIndustryBox {
		padding: 10px 0px;

		.moreOptionTitle {
			font-size: 29rpx;
			font-weight: bold;
			margin: 0 20rpx;
		}

		.industryBox {
			height: 600rpx;

			.industryItemBox {
				height: 100%;
				overflow: scroll;
			}

			.industryItem {
				padding: 20rpx 32rpx;
			}

			.backF5 {
				background: #F5F5F5;
			}

			.backF8 {
				background: #F8F8F8;
			}

			.active {
				color: #fb6316;
				background: #F5F5F5;
			}
		}
	}

	.reserve {
		width: 240rpx;
		margin-right: 40rpx;
		background: #eee;
		color: #000;
		font-size: 24rpx;
		padding: 8rpx 0;
	}

	button::after {
		border: none;
	}

	.confirm {
		flex: 1;
		background: #fb6316;
		color: #fff;
		font-size: 24rpx;
		padding: 8rpx 0;
	}

	.map_box {
		width: 100%;
		position: relative;

		map {
			width: 100%;
			height: 100%
		}
	}

	.map_current_box {
		position: fixed;
		z-index: 9999;
		bottom: 240rpx;
		width: 100%;

		.map_current_btn {
			margin: 0 auto;
			border-radius: 50rpx;
			width: 240rpx;
			padding: 20rpx 0;
			display: flex;
			justify-content: center;
			align-items: center;
			color: #fff;
			background: linear-gradient(to top, #B67642, #E6BF91);
			box-shadow: 0px 0px 10rpx 1px #B3723E;
			font-size: 26rpx;
		}
	}

	.map_tag_box {
		position: fixed;
		z-index: 9999;
		right: 20rpx;
		bottom: 240rpx;

		.map_tag {
			display: flex;
			justify-content: center;
			width: 180rpx;
			background: #fff;
			border-radius: 50rpx;
			padding: 8rpx 0;
			margin-top: 20rpx;
			border: 1rpx solid #B3723E;
		}
	}
</style>